<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //有一个包含工资的数组[1500, 1200, 2000, 2100, 1800]，要求把数组中工资超多2000的删除，剩余的放到新数组里面。
        var arr1 = [1500, 1200, 2000, 2100, 1800];
        arr1.sort();
        var arr2 = [];
        for (var i = 0; i < arr1.length; i++) {
            if (arr1[i] >= 2000) {
                //从第几位开始删除几个
                arr1.splice(i, 2);
            }else {
                //剩余的存储到新数组
                arr2.push(arr1[i]);
            }
        }
        console.log(arr1);
    </script>
</body>

</html>